Option Explicit On 
Option Strict On

Imports System
Imports System.Object
Imports System.Collections
Imports System.Collections.Specialized
Imports Microsoft.VisualBasic.ControlChars

Public Class MethodClass
    Private sMethType As String = "Field"
    Private sMethID As New StringCollection
    Private sMethDesc As String = ""
    'collection of citations -- not strongly typed
    Private cCite As Collection = New Collection
    Private cLWC_b As Collection = New Collection
    Private cCiteLWC As Collection = New Collection

    Public Sub New()
        MyBase.new()
    End Sub

    Public Property MethodType() As String
        Get
            MethodType = sMethType
        End Get
        Set(ByVal Value As String)
            sMethType = Value
        End Set
    End Property

    Public Property MethodID() As StringCollection
        Get
            MethodID = sMethID
        End Get
        Set(ByVal Value As StringCollection)
            sMethID = Value
        End Set
    End Property

    Public Property MethodDesc() As String
        Get
            MethodDesc = sMethDesc
        End Get
        Set(ByVal Value As String)
            sMethDesc = Value
        End Set
    End Property

    ReadOnly Property CiteCount() As Integer
        Get
            CiteCount = cCite.Count
        End Get
    End Property

    ReadOnly Property FetchCite(ByVal cIndex As Integer) As CiteInfo
        Get
            If (cIndex > 0 And cIndex <= cCite.Count) Then
                Return CType(cCite(cIndex), CiteInfo)
            Else
                MessageBox.Show("Index out of bounds of collection", "Methodology Citations", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End Get
    End Property

    ReadOnly Property FetchLWC_b(ByVal cIndex As Integer) As Boolean
        Get
            If (cIndex > 0 And cIndex <= cCite.Count) Then
                Return CType(cLWC_b(cIndex), Boolean)
            Else
                MessageBox.Show("Index out of bounds of collection", "Methodology Citations", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End Get
    End Property

    ReadOnly Property FetchLWC(ByVal cIndex As Integer) As CiteInfo
        Get
            If (cIndex > 0 And cIndex <= cCite.Count) Then
                Return CType(cCiteLWC(cIndex), CiteInfo)
            Else
                MessageBox.Show("Index out of bounds of collection", "Methodology Citations", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End Get
    End Property

    Public Sub CiteRemove(ByVal value As Integer)
        Dim sErrorText As String = "Attempt to remove citation " & value.ToString & " failed." & CrLf
        If (value < 1) Then
            sErrorText = sErrorText & "Index values must be greater than zero!"
            MessageBox.Show(sErrorText, "Index outside of lower bound", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Return
        End If
        If (value <= cCite.Count) Then
            cCite.Remove(value)
            cLWC_b.Remove(value)
            cCiteLWC.Remove(value)
        Else
            sErrorText = sErrorText & "There are only " & cCite.Count.ToString & " citations!"
            MessageBox.Show(sErrorText, "Index value error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub

    Public Sub CiteAdd()
        cCite.Add(New CiteInfo)
        cLWC_b.Add(New Boolean = False)
        cCiteLWC.Add(New CiteInfo)
    End Sub

    Public Sub CiteUpdate(ByVal objCite As CiteInfo, ByVal curindex As Integer)
        'updates the main citation by inserting the new citation before its earlier version, then removing the outdated version
        cCite.Add(objCite, , curindex)
        cCite.Remove(curindex + 1)
    End Sub

    Public Sub LWCUpdate(ByVal bLWC As Boolean, ByVal objCite As CiteInfo, ByVal curindex As Integer)
        'updates the larger work citation by inserting the new citation before its earlier version, then removing the outdated version
        'updates the Boolean indicating whether the larger work citation needs to be processed in the same manner
        cLWC_b.Add(bLWC, , curindex)
        cLWC_b.Remove(curindex + 1)
        cCiteLWC.Add(objCite, , curindex)
        cCiteLWC.Remove(curindex + 1)
    End Sub

End Class
